package com.example.myanimator.mcanvas

import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Path
import android.graphics.drawable.shapes.Shape

/**
 * @author tgw
 * @date 2021/4/2
 * @describe
 */
class PathShapeCustom @JvmOverloads constructor(path: Path, stdWidth: Float, stdHeight: Float) : Shape() {

    var mPath: Path? = null
    var mStdWidth: Float = 0f
    var mStdHeight: Float = 0f
    var mSCaleX: Float = 0f
    var mSCaleY: Float = 0f

    override fun draw(canvas: Canvas?, paint: Paint?) {
        TODO("Not yet implemented")
        canvas?.let<Canvas, Unit> {
            it.save()
            it.scale(mSCaleX, mSCaleY)
            it.drawPath(mPath!!, paint!!)
        }
    }


    override fun onResize(width: Float, height: Float) {
        super.onResize(width, height)
        mSCaleX = width / mStdWidth
        mSCaleY = height / mStdHeight
    }
    /**/

    init {
        this.mPath = path
        this.mStdWidth = stdWidth
        this.mStdHeight = stdHeight
    }
}